package com.colabo.j2ee.web.oaf.security.impl;

import java.util.Collection;

import org.springframework.security.access.AccessDecisionVoter;
import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.core.Authentication;

import com.colabo.j2ee.web.oaf.security.AuthUtil;

public class AdminVoter implements AccessDecisionVoter {
	public boolean supports(ConfigAttribute attribute) {
		return true;
	}

	public boolean supports(Class clazz) {
		return true;
	}

	public int vote(Authentication authentication, Object object, Collection<ConfigAttribute> attributes) {
		if (AuthUtil.isAdmin(authentication)) {
			return ACCESS_GRANTED;
		}
		return ACCESS_ABSTAIN;
	}
}
